'''
用户账户相关功能：注册、短信、登陆、注销
'''
from django import forms
from django.http.response import HttpResponse
from django.shortcuts import render
from web.forms.account import RegisterModelForm,SendSmsForm
from django.http import JsonResponse


def register(request):
    # 实例化forms
    form = RegisterModelForm()
    return render(request,'register.html',{'form':form})


def send_sms(request):
    """发送短信"""
    
    # 将手机号传给forms进行校验
    form = SendSmsForm(request,data=request.GET)
    
    if form.is_valid():
        return JsonResponse({'status':True})
    return JsonResponse({'status':False,'error':form.errors})